﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Html;
using System.Linq.Expressions;

namespace DddCms.Models.UIComponent.Form
{
    public static class EditForExtensions
    {
        public static EditItem Edit<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression)
        {
            EditItem info = new EditItem()
            {
                Value = html.EditorFor(expression),
                Error = html.ValidationMessageFor(expression),
                Display = html.LabelFor(expression)
            };
            return info;
        }
    }
}